package javacommon.base;

import java.io.Serializable;
import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.transaction.annotation.Transactional;
/**
 * @author 
 */
@Transactional
public interface BaseService <E,Q,PK extends Serializable>{
	
	@Transactional(readOnly=true)
	public E getById(PK id) throws DataAccessException;
	
	@Transactional(readOnly=true)
	public List<E> findAll() throws DataAccessException;
	
	@Transactional(readOnly=true)
	public List<E> findAllByQuery(Q query) throws DataAccessException;
	
	/** 根据id检查是否插入或是更新数据 */
	public E saveOrUpdate(E entity) throws DataAccessException;
	
	/** 插入数据 */
	public E save(E entity) throws DataAccessException;
	
	public void removeById(PK id) throws DataAccessException;
	
	public E update(E entity) throws DataAccessException;
	
	@Transactional(readOnly=true)
	public boolean isUnique(E entity, String uniquePropertyNames) throws DataAccessException;
	
}
